home *** CD-ROM | disk | FTP | other *** search
/ Champak 141 / (Vol 141) Oct 17 2011.iso / Games / despereaux-swings.swf / scripts / Box2D / Collision / Shapes / b2Shape.as < prev    next >
Encoding:
Text File  |  2011-10-17  |  5.7 KB  |  228 lines

  1. package Box2D.Collision.Shapes
  2. {
  3.    import Box2D.Collision.b2AABB;
  4.    import Box2D.Collision.b2BroadPhase;
  5.    import Box2D.Collision.b2Pair;
  6.    import Box2D.Collision.b2Segment;
  7.    import Box2D.Common.Math.b2Vec2;
  8.    import Box2D.Common.Math.b2XForm;
  9.    import Box2D.Dynamics.b2Body;
  10.    
  11.    public class b2Shape
  12.    {
  13.       
  14.       public static const e_polygonShape:int = 1;
  15.       
  16.       private static var s_resetAABB:b2AABB = new b2AABB();
  17.       
  18.       private static var s_syncAABB:b2AABB = new b2AABB();
  19.       
  20.       private static var s_proxyAABB:b2AABB = new b2AABB();
  21.       
  22.       public static const e_unknownShape:int = -1;
  23.       
  24.       public static const e_circleShape:int = 0;
  25.       
  26.       public static const e_shapeTypeCount:int = 2;
  27.        
  28.       
  29.       public var m_type:int;
  30.       
  31.       public var m_sweepRadius:Number;
  32.       
  33.       public var m_density:Number;
  34.       
  35.       public var m_filter:b2FilterData;
  36.       
  37.       public var m_friction:Number;
  38.       
  39.       public var m_next:b2Shape;
  40.       
  41.       public var m_restitution:Number;
  42.       
  43.       public var m_userData:*;
  44.       
  45.       public var m_isSensor:Boolean;
  46.       
  47.       public var m_proxyId:uint;
  48.       
  49.       public var m_body:b2Body;
  50.       
  51.       public function b2Shape(param1:b2ShapeDef)
  52.       {
  53.          super();
  54.          m_userData = param1.userData;
  55.          m_friction = param1.friction;
  56.          m_restitution = param1.restitution;
  57.          m_density = param1.density;
  58.          m_body = null;
  59.          m_sweepRadius = 0;
  60.          m_next = null;
  61.          m_proxyId = b2Pair.b2_nullProxy;
  62.          m_filter = param1.filter.Copy();
  63.          m_isSensor = param1.isSensor;
  64.       }
  65.       
  66.       public static function Destroy(param1:b2Shape, param2:*) : void
  67.       {
  68.       }
  69.       
  70.       public static function Create(param1:b2ShapeDef, param2:*) : b2Shape
  71.       {
  72.          switch(param1.type)
  73.          {
  74.             case e_circleShape:
  75.                return new b2CircleShape(param1);
  76.             case e_polygonShape:
  77.                return new b2PolygonShape(param1);
  78.             default:
  79.                return null;
  80.          }
  81.       }
  82.       
  83.       public function TestPoint(param1:b2XForm, param2:b2Vec2) : Boolean
  84.       {
  85.          return false;
  86.       }
  87.       
  88.       public function GetSweepRadius() : Number
  89.       {
  90.          return m_sweepRadius;
  91.       }
  92.       
  93.       public function GetNext() : b2Shape
  94.       {
  95.          return m_next;
  96.       }
  97.       
  98.       public function ComputeSweptAABB(param1:b2AABB, param2:b2XForm, param3:b2XForm) : void
  99.       {
  100.       }
  101.       
  102.       public function GetType() : int
  103.       {
  104.          return m_type;
  105.       }
  106.       
  107.       public function GetRestitution() : Number
  108.       {
  109.          return m_restitution;
  110.       }
  111.       
  112.       public function GetFriction() : Number
  113.       {
  114.          return m_friction;
  115.       }
  116.       
  117.       public function GetFilterData() : b2FilterData
  118.       {
  119.          return m_filter.Copy();
  120.       }
  121.       
  122.       public function TestSegment(param1:b2XForm, param2:Array, param3:b2Vec2, param4:b2Segment, param5:Number) : Boolean
  123.       {
  124.          return false;
  125.       }
  126.       
  127.       public function RefilterProxy(param1:b2BroadPhase, param2:b2XForm) : void
  128.       {
  129.          var _loc3_:b2AABB = null;
  130.          var _loc4_:Boolean = false;
  131.          if(m_proxyId == b2Pair.b2_nullProxy)
  132.          {
  133.             return;
  134.          }
  135.          param1.DestroyProxy(m_proxyId);
  136.          _loc3_ = s_resetAABB;
  137.          ComputeAABB(_loc3_,param2);
  138.          if(_loc4_ = param1.InRange(_loc3_))
  139.          {
  140.             m_proxyId = param1.CreateProxy(_loc3_,this);
  141.          }
  142.          else
  143.          {
  144.             m_proxyId = b2Pair.b2_nullProxy;
  145.          }
  146.       }
  147.       
  148.       public function SetFilterData(param1:b2FilterData) : void
  149.       {
  150.          m_filter = param1.Copy();
  151.       }
  152.       
  153.       public function GetUserData() : *
  154.       {
  155.          return m_userData;
  156.       }
  157.       
  158.       public function Synchronize(param1:b2BroadPhase, param2:b2XForm, param3:b2XForm) : Boolean
  159.       {
  160.          var _loc4_:b2AABB = null;
  161.          if(m_proxyId == b2Pair.b2_nullProxy)
  162.          {
  163.             return false;
  164.          }
  165.          _loc4_ = s_syncAABB;
  166.          ComputeSweptAABB(_loc4_,param2,param3);
  167.          if(param1.InRange(_loc4_))
  168.          {
  169.             param1.MoveProxy(m_proxyId,_loc4_);
  170.             return true;
  171.          }
  172.          return false;
  173.       }
  174.       
  175.       public function ComputeMass(param1:b2MassData) : void
  176.       {
  177.       }
  178.       
  179.       public function IsSensor() : Boolean
  180.       {
  181.          return m_isSensor;
  182.       }
  183.       
  184.       public function DestroyProxy(param1:b2BroadPhase) : void
  185.       {
  186.          if(m_proxyId != b2Pair.b2_nullProxy)
  187.          {
  188.             param1.DestroyProxy(m_proxyId);
  189.             m_proxyId = b2Pair.b2_nullProxy;
  190.          }
  191.       }
  192.       
  193.       public function UpdateSweepRadius(param1:b2Vec2) : void
  194.       {
  195.       }
  196.       
  197.       public function ComputeAABB(param1:b2AABB, param2:b2XForm) : void
  198.       {
  199.       }
  200.       
  201.       public function GetBody() : b2Body
  202.       {
  203.          return m_body;
  204.       }
  205.       
  206.       public function CreateProxy(param1:b2BroadPhase, param2:b2XForm) : void
  207.       {
  208.          var _loc3_:b2AABB = null;
  209.          var _loc4_:Boolean = false;
  210.          _loc3_ = s_proxyAABB;
  211.          ComputeAABB(_loc3_,param2);
  212.          if(_loc4_ = param1.InRange(_loc3_))
  213.          {
  214.             m_proxyId = param1.CreateProxy(_loc3_,this);
  215.          }
  216.          else
  217.          {
  218.             m_proxyId = b2Pair.b2_nullProxy;
  219.          }
  220.       }
  221.       
  222.       public function SetUserData(param1:*) : void
  223.       {
  224.          m_userData = param1;
  225.       }
  226.    }
  227. }
  228.